package cn.bs.ktv.model.event;

import com.blankj.utilcode.util.GsonUtils;
import com.blankj.utilcode.util.StringUtils;

import java.io.Serializable;

public class MsgEvent implements Serializable {
    private static final long serialVersionUID = -1805633876262324244L;

    private String cmd;

    private String body;

    public MsgEvent() {

    }

    public MsgEvent(String cmd, String body) {
        this.cmd = cmd;
        this.body = body;
    }

    public String getCmd() {
        return cmd;
    }

    public void setCmd(String cmd) {
        this.cmd = cmd;
    }

    public String getBody() {
        return body;
    }

    public void setBody(String body) {
        this.body = body;
    }

    public <T> T getData(Class<T> tClass) {
        if (StringUtils.isEmpty(body)) {
            return null;
        }

        return GsonUtils.fromJson(body, tClass);
    }
}
